<script setup lang="ts">
import { ref } from "vue";
const money = ref(100)
const buy = (name: string, price: number) => {
    console.log(name);
    money.value-=price
 }
</script>
<template>
    <div>
        <div>
            <h3>黑马自动售货机</h3>
            <button @click="buy('可乐',4)">可乐4元</button>
            <button @click="buy('咖啡',10)">咖啡10元</button>
            <button @click="buy('牛奶',8)">牛奶8元</button>
            <button @click="buy('泡面',5)">泡面5元</button>
        </div>
           <p>银行卡余额：{{ money }}元</p>     
    </div>
  
</template>
<style>
    .box{
        background-color: #27152b;
        width: 200px;
        height: 100px;
    }
</style>

